package com.parsechina.hpush.broker.internal.message;

import com.parsechina.hpush.broker.parser.PublishMessage;
import com.parsechina.hpush.broker.utils.ByteUtils;

import java.io.Serializable;

public class IgniteMessage implements Serializable {

    private static final long serialVersionUID = -9190626606154004946L;
    private final String clientId;
    private final int qos;
    private final byte[] payload;
    private final String topic;

    public IgniteMessage(PublishMessage msg) {
        this.clientId = msg.getClientId();
        this.topic = msg.getTopicName();
        this.qos = msg.getQos().value();
        this.payload = ByteUtils.convert(msg.getPayload());
    }

    public String getClientId() {
        return clientId;
    }

    public int getQos() {
        return qos;
    }

    public byte[] getPayload() {
        return payload;
    }

    public String getTopic() {
        return topic;
    }
}
